package SqlDatabase;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBHandler {
	private Context ctx;
	private DBHelper helper;
	private SQLiteDatabase db;
	
	public DBHandler(Context ctx)
	{
		
	}
	
	public static DBHandler open(Context ctx)
	{
		DBHandler handler = new DBHandler(ctx);
		return handler;
	}
	
	public void close()
	{
		helper.close();
	}
	
	public long insert(String name, String score)
	{
		ContentValues values = new ContentValues();
		values.put("name", name);
		
		long result = db.insert("db_friend", null, values);
		return result;
	}
	
	public Cursor selectAll()
	{
		Cursor cursor = db.query(true, "db_friend", new String[]{"code","name"}
										, null, null, null, null, null, null);
		return cursor;
		
	}
}